<?php 
class AreaModel extends Model{
	private $table1 = 'province';
	private $table2 = 'city';
	private $table3 = 'area';
	
	/**
	 * 获取地区全名
	 * @param $provcode,$citycode,$area_id
	 */
	public function getAllName($provcode,$citycode,$area_id){
		$str = '';
		if($provcode>0){
			$provname =M($this->table1)->where(array('code'=>$provcode))->field('name')->find();
			$str .=$provname['name'];
			if($citycode>0){
				$cityname = M($this->table2)->where(array('code'=>$citycode))->field('name')->find();
				$str.="-".$cityname['name'];
				if($area_id>0){
					$areaname = M($this->table3)->where(array('code'=>$area_id))->getField('name')->find();
					$str.="-".$areaname['name'];
				}
			} 
		}
		return $str;
		
	}
}
?>